﻿using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using SmartSpace.Core;
using System;
using SsTool.Common;
using System.Windows.Input;

namespace SsTool.Base
{
    /// <summary>
    /// Interaction logic for NavigationListPage.xaml
    /// </summary>
    public partial class NavigationListPage : Page
    {
        /// <summary>
        /// 新建时使用的navigation
        /// </summary>
        private Navigation _newNavigation;

        public NavigationListPage()
        {
            InitializeComponent();

            this.Loaded += new RoutedEventHandler(NavigationListPage_Loaded);
        }

        void NavigationListPage_Loaded(object sender, RoutedEventArgs e)
        {
            LoadDatas();
        }

        private void LoadDatas()
        {
            ICoreService service = App.Get<ICoreService>();
            this._ctlListApplication.ItemsSource = service.GetApplications();
        }

        private void _ctlListApplication_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            SmartSpace.Core.Application selectedItem = _ctlListApplication.SelectedItem as SmartSpace.Core.Application;
            if (selectedItem != null)
            {
                _ctlNavigationPart.SetApplication(selectedItem);
            }
        }
    }
}
